# 9.7(改自9.5)
class User:
    def __init__(self,first_name,last_name,location,telephone):
        self.first = first_name.title()
        self.last = last_name.title()
        self.loc = location.title()
        self.tele = telephone

        self.login_attempts = 0

    def describe_user(self):
        print(f"name: {self.first} {self.last}")
        print(f"location: {self.loc}")
        print(f"Telephone: {self.tele}")

    def greet_user(self):
        print(f"Hello! {self.first} {self.last}")

    def increment_login_attempts(self):
        self.login_attempts += 1

    def reset_login_attempts(self):
        self.login_attempts = 0

zhangsan = User('zhang','san','qinguo','7862195')
zhangsan.describe_user()
zhangsan.greet_user()


wangwu = User('wwang','wu','hanguo','8212565')
wangwu.increment_login_attempts()
wangwu.increment_login_attempts()
wangwu.increment_login_attempts()
print(f"wangwu's login attempts:{wangwu.login_attempts}")

wangwu.reset_login_attempts()
print(f"wangwu's login attempts:{wangwu.login_attempts}\n")


class Admin(User):
    def __init__(self,first_name,last_name,location,telephone):
        super().__init__(first_name,last_name,location,telephone)
        self.privileges = []
     
    def show_privileges(self):
        print("\nPrivileges:")
        for privilege in self.privileges:
            print(f"-{privilege}")

zhaoliu = Admin('zhang','san','weiguo',666)
zhaoliu.describe_user()

zhaoliu.privileges = ['can add post','can delete post','can ban user']
zhaoliu.show_privileges()